import request from "@/utils/request";
import { jsonToPath } from "@/utils/common";
import type {
  LoginInfo,
  LoginInfoResp,
  UserInfoResp,
  UserDataPageResp,
} from "./type";
import { BasePageReq } from "../baseType";

enum API {
  LOGIN_URL = "/admin/acl/index/login",
  USER_INFO_URL = "/admin/acl/index/info",
  LOGOUT_URL = "/admin/acl/index/logout",
  MENU_URL = "/admin/acl/index/menu",
  //获取用户列表
  USER_LIST_URL = "/admin/acl/user",
}

export const login = (data: LoginInfo) => {
  return request.post<any, LoginInfoResp>(API.LOGIN_URL, data);
};
export const userInfo = () => {
  return request.get<any, UserInfoResp>(API.USER_INFO_URL);
};
export const logout = () => {
  return request.post<any, any>(API.LOGOUT_URL);
};
export const getMenu = () => {
  return request.get<any, any>(API.MENU_URL);
};

export const getUserList = (params: BasePageReq) => {
  return request.get<any, UserDataPageResp>(
    API.USER_LIST_URL + jsonToPath(params),
  );
};
